package com.pinyougou.sellergoods.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbBrandMapper;
import com.pinyougou.pojo.TbBrand;
import com.pinyougou.sellergoods.service.BrandService;

import entity.PageResult;

@Service
public class BrandServiceImpl implements BrandService{
	
	@Autowired
	private TbBrandMapper tbBrandMapper;

	@Override
	public List<TbBrand> findAll() {
		return tbBrandMapper.selectByExample(null);
	}

	@Override
	public PageResult<TbBrand> findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		Page<TbBrand> page = (Page<TbBrand>) tbBrandMapper.selectByExample(null);
		
		return new PageResult<>(page.getTotal(), page.getResult());
	}

	@Override
	public void save(TbBrand tbBrand) {
		tbBrandMapper.insert(tbBrand);
	}

	@Override
	public TbBrand findOne(long id) {
		return tbBrandMapper.selectByPrimaryKey(id);
	}

	@Override
	public void edit(TbBrand tbBrand) {
		tbBrandMapper.updateByPrimaryKey(tbBrand);
	}

	@Override
	public void delet(long[] ids) {
		for (long id : ids) {
			tbBrandMapper.deleteByPrimaryKey(id);
		}
	}

	
}
